*** Settings ***
Library    Collections

*** Test Cases ***
My Test
#    ctrl+mouse->查看关键字
#    ${var1}    Set Variable    Robot
#    Log     ${var1}        # Robot
    #定义列表
    @{list1}    Create List    hello  Robot  framework
    Log    ${list1}    # ['hello', 'Robot', 'framework']

    #访问列表元素
    Log    @{list1}
    Log    ${list1[0]}       # hello
    Log    ${list1[1]}        # robot
    # 遍历整个列表
#    FOR    ${item}    IN    @{list1}
#        Log    ${item}  # 输出每个元素
#    END
    #循环输出列表
    FOR    ${item}    IN     @{list1}
        Run Keyword If  '${item}'=='Banana'      Log    bab
        Log    ${item}
    END
    
#列表添加操作
Append Example
    ${list}=    Create List
    Append To List    ${list}    element1
    Append To List    ${list}    element2
    Log    ${list}
Update Example
    ${list1}=        Create List    python  java  pycharm
    # 修改元素需要索引
    Set List Value    ${list1}    1     newlement
    Log Many    @{list1}
# 删除
Remove Example
    ${list}=    Create List    element1    element2    element3
    Remove From List    ${list}    1    # 移除索引为1的元素
    Log    ${list}
